package Easy有效的字母异位词;

import org.testng.annotations.Test;

import java.util.Arrays;

public class Solution {
    public boolean isAnagram(String s, String t) {
        char[] a = s.toCharArray();
        char[] b = t.toCharArray();
        Arrays.sort(a);
        Arrays.sort(b);
        if (s.length() != t.length())
            return false;
        for (int i = 0; i < a.length; i++) {
            if (a[i]!=b[i])
                return false;
        }
        return true;
    }
    @Test
    public void test(){
        String s = "rat";
        String t = "car";
        System.out.println(isAnagram(s, t));
    }
}
